package com.youngwang.sort;

import com.google.common.collect.Lists;
import com.youngwang.lambda.Person;

import java.util.Collections;
import java.util.List;

/**
 * 自定义自然排序
 *
 * @author youngwang
 *         Date: 2016/10/9
 */
public class SortTest {

    public static void main(String[] args) {
       /* String[] strings = {"1", "a", "4", "2"};
        List<String> stringList = Arrays.asList(strings);
        stringList.forEach(System.out::println);
        Collections.sort(stringList);
        stringList.forEach(System.out::println);
        Arrays.sort(strings, (String o1, String o2) -> o2.compareTo(o1));
        for (String s : strings ){
            System.out.println(s);
        }
        Arrays.sort(strings);
        for (String s : strings ){
            System.out.println(s);
        }*/

        Person person1 = new Person("wang","yang",23);
        Person person2 = new Person("Wang","Yang",24);

        List<Person> persons = Lists.newArrayList();

        persons.add(person1);
        persons.add(person2);

        Collections.sort(persons, (Person p1, Person p2) -> p1.compareTo(p2));
        persons.forEach(System.out :: println);


    }

}
